package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.FriendshipReply;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.mapper.FriendshipReplyMapper;
import cn.wolfcode.trip.base.service.IFriendshipCommentService;
import cn.wolfcode.trip.base.service.IFriendshipReplyService;
import cn.wolfcode.trip.base.util.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FriendshipReplyServiceImpl implements IFriendshipReplyService {

    @Autowired
    private FriendshipReplyMapper replyMapper;

    @Override
    public FriendshipReply saveReply(FriendshipReply reply) {
        User currentUser = UserContext.getCurrentUser();
        reply.setUser(currentUser);
        replyMapper.insert(reply);
        return reply;
    }

    @Override
    public int selectTotalCountForUnreadComment() {

        return replyMapper.selectTotalCountForUnreadComment(UserContext.getCurrentUser());
    }

    @Override
    public List<FriendshipReply> selectReply() {
        Long id = UserContext.getCurrentUser().getId();
        Boolean read = false;

        return replyMapper.selectReply(id,read);
    }

    @Override
    public void updateRead(Long friendshipReplyId) {
        replyMapper.updateRead(friendshipReplyId);
    }
}
